package PrlServer::API;

use 5.012004;
use strict;
use warnings;
use Exporter 'import';
use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS );
use Socket;

$VERSION = 0.01;

@ISA = qw( Exporter );
@EXPORT = ();
@EXPORT_OK = qw( $API_release );
%EXPORT_TAGS = (DEFAULT => [ qw( $API_release ) ]);

our $API_release = "J14";


1;
__END__
# Below is stub documentation for your module. You'd better edit it!

=head1 NAME

PrlServer::API - A secondary API for the Socket API.

=head1 SYNOPSIS

  # $API_release is the current release label
  use PrlServer::API qw( $API_release );
  
  # Create a new API object handle
  my($server) = PrlServer::API->new (
    host => "LocalHost",
    proto => 'tcp',
    port => 1234,
    ip => '127.0.0.1'
  );
  
  # Initialize your API handle as a server
  my $status = $server->createServer ();
  die "Couldn't create server!\n" if $status == -1;
  
  # Send the word "Hi" over port 1234 using protocol TCP
  $status = $server->serverPortOut ("Hi");
  die "Couldn't send data from server\n" if $status == -1;
  
  # Create another API object handle
  my($client) = PrlServer::API->new (
    host => "LocalHost/Client",
    proto => 'tcp',
    port => 1234,
    ip => '127.0.0.1'
  );
  
  # Get the word "Hi" from the port
  my $word = $client->clientPortIn (); # $word = "Hi";
  die "Couldn't read data from client\n" if $word == -1;

  # Send "How are you?" to server
  $status = $client->clientPortOut ("How are you?");
  die "Couldn't write to port (from client)\n" if $status == -1;
  
  # Recieve this
  $status = $server->serverPortIn (); # $status = "How are you?";
  die "Couldn't create server!\n" if $status == -1;
  
  
=head1 DESCRIPTION

  Used to easily create TCP socket servers and clients, and transmit data over the ports.

=head2 EXPORT

  $API_release -- The release label
  
=head1 SEE ALSO

  Socket

=head1 AUTHOR

Matthew Caswell, E<lt>caswellrienzo@gmail.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2013 by Matthew Caswell

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.12.4 or,
at your option, any later version of Perl 5 you may have available.


=cut
